home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ghostscript / src / gzcolor.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  4KB  |  94 lines

  1. /* Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gzcolor.h */
  20. /* Private definition of color representation for Ghostscript */
  21. #include "gscolor.h"            /* client interface */
  22. #include "gxfmap.h"
  23. #include "gxlum.h"
  24.  
  25. /*
  26.  * The following parameters are computed from client color specifications,
  27.  * and kept current through changes in transfer function or device.
  28.  * If the halftone is a colored tile, color1 == color2 == gx_no_color_index,
  29.  * and halftone_level == -1.  (Colored tiles are not currently used.)
  30.  */
  31. typedef struct gx_device_color_s gx_device_color;
  32. struct gx_device_color_s {
  33.     gx_color_index color1;        /* device color, or */
  34.                     /* darker color for halftoning */
  35.     gx_color_index color2;        /* lighter color for halftoning */
  36.     int halftone_level;        /* number of spots to whiten */
  37.                     /* when halftoning, 0 if */
  38.                     /* halftoning not needed, */
  39.                     /* <0 if color halftone */
  40.     struct gx_bitmap_s *tile;    /* pointer to cached halftone */
  41. };
  42. #define color_is_pure(pdevc)\
  43.   ((pdevc)->halftone_level == 0)
  44. #define color_is_color_halftone(pdevc)\
  45.   ((pdevc)->halftone_level < 0)
  46.  
  47. /* Procedures for rendering colors specified by fractions. */
  48.  
  49. #define cmap_proc_gray(proc)\
  50.   void proc(P3(frac, gx_device_color *, const gs_state *))
  51. #define cmap_proc_rgb(proc)\
  52.   void proc(P5(frac, frac, frac, gx_device_color *, const gs_state *))
  53. #define cmap_proc_cmyk(proc)\
  54.   void proc(P6(frac, frac, frac, frac, gx_device_color *, const gs_state *))
  55.  
  56. typedef struct gx_color_map_procs_s {
  57.     cmap_proc_gray((*map_gray));
  58.     cmap_proc_rgb((*map_rgb));
  59.     cmap_proc_cmyk((*map_cmyk));
  60. } gx_color_map_procs;
  61.  
  62. /* A fast version of gz_fill_rectangle. */
  63. /* Note that it takes additional arguments. */
  64. #define gz_fill_rectangle_open(dev, xi, yi, w, h, fill_proc, tile_proc, pdevc, pgs)\
  65.   (color_is_pure(pdevc) ?\
  66.     (*fill_proc)(dev, xi, yi, w, h, pdevc->color1) :\
  67.     (*tile_proc)(dev, pdevc->tile, xi, yi, w, h,\
  68.     pdevc->color1, pdevc->color2,\
  69.     pgs->phase_mod.x, pgs->phase_mod.y) )
  70.  
  71. /* A color transfer function and cache. */
  72. /* log2... must not be greater than frac_bits. */
  73. #define log2_transfer_map_size 8
  74. #define transfer_map_size (1 << log2_transfer_map_size)
  75. typedef struct gx_transfer_map_s {
  76.     frac_map(log2_transfer_map_size);
  77. } gx_transfer_map;
  78.  
  79. /* Map a color fraction through a transfer map. */
  80. extern frac gx_color_frac_map(P2(frac, const frac *));
  81. #define gx_map_color_frac(pgs,cf,m)\
  82.   gx_color_frac_map(cf, &pgs->transfer.m->values[0])
  83. /****************
  84. #if log2_transfer_map_size <= 8
  85. #  define byte_to_tmx(b) ((b) >> (8 - log2_transfer_map_size))
  86. #else
  87. #  define byte_to_tmx(b)\
  88.     (((b) << (log2_transfer_map_size - 8)) +\
  89.      ((b) >> (16 - log2_transfer_map_size)))
  90. #endif
  91. #define gx_map_color_frac_byte(pgs,b,m)\
  92.  (pgs->transfer->m.values[byte_to_tmx(b)])
  93.  ****************/
  94.